import { EventName } from "./Const";
import { EventManager } from "./EventManager";

export class UserData {
    private static coin: number = 1111111;
    public static get Coin(): number { return this.coin; }

    private static attackScale: number = 0;
    public static get AttackScale(): number { return this.attackScale; }

    private static trajectory: number = 1;  // 弹道
    public static get Trajectory(): number { return this.trajectory; }

    public static addCoin(amount: number) {
        this.coin += amount;

        EventManager.I.emit(EventName.COIN_CHANGED, this.coin);
    }

    // 消耗 Coin
    public static spendCoin(amount: number): boolean {
        if (this.coin >= amount) {
            this.coin -= amount;
            EventManager.I.emit(EventName.COIN_CHANGED, this.coin);
            return true;
        }
        return false;
    }

    // 增加攻击速度
    public static addAttackScale(amount: number) {
        this.attackScale += amount;
    }

    public static addTrajectory(amount: number) {
        this.trajectory += amount;
    }
} 